﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace DARE
{
    public class CListBoxData : CWidgetData
    {
        public int count;
        public float widgetHeight;
        public List<string> list;
        public int displayCount;
        public Color hlColor;
        public string selectedWidget;

        public override void FillDataStructure(CWidget wid)
        {
            CListBox w = wid as CListBox;
            base.FillDataStructure(wid);
            count = w.Count;
            widgetHeight = w.CWidgetHeight;
            list = new List<string>();
            foreach (CWidget widget in w.CWidgetList)
                list.Add(widget.Name);
            displayCount = w.DisplayCount;
            hlColor = w.HLColor;
            if (w.SelectedCWidget != null)
                selectedWidget = w.SelectedCWidget.Name;
        }

        public override void FillFromDataStructure(ref CWidget wid, CHUDSystem hud)
        {
            base.FillFromDataStructure(ref wid, hud);
            (wid as CListBox).CWidgetHeight = widgetHeight;
            foreach (string str in list)
                (wid as CListBox).CWidgetList.Add(hud.GetElement(str));
            (wid as CListBox).HLColor = hlColor;
            if (selectedWidget != null)
                (wid as CListBox).SelectWidget(hud.GetElement(selectedWidget));
        }
    }
}
